# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=onedrive
pkgver=2.4.25
pkgrel=2
pkgdesc="OneDrive Client for Linux"
url="https://abraunegg.github.io"
# LDC only on these architectures
arch="x86_64 aarch64"
license="GPL-3.0-only"
makedepends="autoconf automake chrpath curl-dev ldc libnotify-dev sqlite-dev"
checkdepends="bash"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver-2.tar.gz::https://github.com/abraunegg/onedrive/archive/v$pkgver.tar.gz
	onedrive.confd
	onedrive.initd
	"

prepare() {
	default_prepare
	autoreconf -fiv
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	bash tests/makefiles.sh
}

package() {
	make DESTDIR="$pkgdir" install
	chrpath -d "$pkgdir"/usr/bin/onedrive
	install -Dm 755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm 644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
}

openrc() {
	default_openrc
	amove etc/logrotate.d/onedrive
}

sha512sums="
bbf1a87be25f69041a36f41967ee5ee692faae012f38d050fdeca7de1fc35c4ff79bf597032354fc7421699f2e9b75b458364c45c17de2db112f884dac42d781  onedrive-2.4.25-2.tar.gz
0a87c60562076d99932b81e1d13ee5791b612532cf3df4ee023dde26933104d069d1053571cbbec0005bc19c6ca9bf8075ef252891bbfd2f37cacb5e50abc3de  onedrive.confd
5eafc9eadbf49b8cd1e5fbcbe5e48ae475ac7cb0faa29b3daef19400d074613cac4e7b79a00d02d99232d20b773cd869fbdd04c1819760d2ef94106a52beaad0  onedrive.initd
"
